home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!netnews
- From: swampwiz@ix.netcom.com(Jean P. Laborde )
- Newsgroups: comp.lang.c++
- Subject: OOPS! - Re: How to delete array of pointers?
- Date: 11 Feb 1996 14:42:27 GMT
- Organization: Netcom
- Message-ID: <4fkv8j$kb@cloner3.netcom.com>
- References: <4fgvsu$5q4@eng_ser1.erg.cuhk.hk> <4fi8rd$738@reader2.ix.netcom.com>
- NNTP-Posting-Host: ix-no1-18.ix.netcom.com
- X-NETCOM-Date: Sun Feb 11 6:42:27 AM PST 1996
-
- OOPS !
-
- In <4fi8rd$738@reader2.ix.netcom.com> swampwiz@ix.netcom.com(Jean P.
- Laborde ) writes:
- >
- >In <4fgvsu$5q4@eng_ser1.erg.cuhk.hk> ywleung@cs.cuhk.hk (Marty McFly)
- >writes:
- >>
- >>If I write the following code in a function:
- >>
- >> int** ptr;
- >> ptr = new int*[1000];
- >>
- >>Is this code means allocating 1000 integer pointers which is pointed
- >by ptr?
- >>And then somehow I assign integer variable to ptr[0], ptr[1], ... and
- >so on.
- >>So at the end of the function, how can I reclaim just those pointers?
-
- >The key
- >>point is that those integer variable assigned to the pointers should
- >not be
- >>deleted.
- >>
- >>Regards,
- >>Marty McFly.
- >
-
- I mistakenly said:
-
- >how about:
- >
- >for(int i=0;i<1000;i++)
- > delete ptr[i];
- >delete ptr;
- >
- >
-
- I should have said at the last line
-
- delete ptr [];
-
-
-